package com.code.leetcode.offer;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/7/31 11:02
 */
public class The16 {
    public double myPow(double x, int n) {
        int temp_n = n;
        double ans = 1;
        while (n != 0) {
            if ((n & 1 )!= 0) {
                ans *= x;
            }
            x *= x;
            n /= 2;
        }
        return temp_n  > 0 ? ans : 1 / ans;
    }
}
